<?php

/**
 * demo actions.
 *
 * @package    TutorMe
 * @subpackage demo
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class demoActions extends sfActions
{
  /**
   * Executes index action
   *
   */
  public function executeIndex()
  {
    $this->students = DemoAjaxPeer::getAllByRank();
  }

  public function executeAjaxsort()
  {
    $order = $this->getRequestParameter('ordered_list');
    $flag = DemoAjaxPeer::doSort($order);

    return $flag ? sfView::SUCCESS : sfView::ERROR;
  }
	
  public function executeEditname()
  {
    $student = DemoAjaxPeer::retrieveByPK($this->getRequestParameter('id'));

    if ($this->getRequestParameter('value') != "")
    {
	$student->setName($this->getRequestParameter('value'));
	$student->save();

	$this->value = $this->getRequestParameter('value');
    }
    else
    {
	$this->value = $student->getName();
    }
  }

  public function executeAutocomplete()
  {
    $this->students = DemoAjaxPeer::getStudentsLike($this->getRequestParameter('searchbox')); 
  }
}
